package com.hub.wc;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

import java.util.Arrays;

public class MyFlatMapFunction implements FlatMapFunction<String, Tuple2<String, Integer>> {

    @Override
    public void flatMap(String s, Collector<Tuple2<String, Integer>> collector) throws Exception {
        System.out.println("处理："+s);
        String[] words = s.split(" |, ");
        Arrays.stream(words).forEach(item->{
            Tuple2<String , Integer> table = new Tuple2(item, 1);
            collector.collect(table);
        });
    }
}